unit supplier;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  StdCtrls, Buttons, Sqlite3DS;

type

  { TSupplierForm }

  TSupplierForm = class(TForm)
    AddressMemo: TMemo;
    ContactName: TLabeledEdit;
    Label1: TLabel;
    Label2: TLabel;
    SupplierName: TLabeledEdit;
    AccountNum: TLabeledEdit;
    TopPanel: TPanel;
    PostCode: TLabeledEdit;
    Telephone: TLabeledEdit;
    Email: TLabeledEdit;
    WebsiteAddress: TLabeledEdit;
    MainPanel: TPanel;
    NotesMemo: TMemo;
    Notebook: TNotebook;
    OKButton: TBitBtn;
    CancelButton: TBitBtn;
    ButtonPanel: TPanel;
    ContactPage: TPage;
    NotesPage: TPage;
    procedure OKButtonClick ( Sender: TObject ) ;
  private
    { private declarations }
  public
    { public declarations }
    supplierid: Integer;
    function ShowNew: TModalResult;
    function ShowEdit: TModalResult;
  end; 

var
  SupplierForm: TSupplierForm;

implementation
{$R *.lfm}


uses fpstructs, fposUtils;

{ TSupplierForm }

procedure TSupplierForm.OKButtonClick ( Sender: TObject ) ;
var
  testStr:string;
begin
  testStr := Trim(SupplierName.Text);
  if Length(testStr) > 2
     then ModalResult := mrOK
     else
       begin
         MessageDlg('Error','Supplier Name must be at least 2 characters', mtError, [mbOK], 0);
         SupplierName.SetFocus;
         exit;
       end;
end;

function TSupplierForm.ShowNew: TModalResult;
begin
  Caption := 'New supplier...';
  Result := ShowModal;
  {if Result = mrOK then
     begin
       if ExecuteSQL(SYSTEM_CONFIG,'INSERT INTO Suppliers (name,address,postcode,telephone,email,contact,notes,website) '
                  + 'VALUES('''+ EscapeQuotes( SupplierName.Text )
                  + ''',''' + EscapeQuotes( AddressMemo.Text )
                  + ''',''' + PostCode.Text
                  + ''',''' + Telephone.Text
                  + ''',''' + Email.Text
                  + ''',''' + EscapeQuotes( ContactName.Text )
                  + ''',''' + EscapeQuotes( NotesMemo.Text )
                  + ''',''' + WebsiteAddress.Text + ''' ) ')=0
          then exit
          else Result := mrAbort;
     end; }
end;

function TSupplierForm.ShowEdit: TModalResult;
begin
 end ;

initialization


end.

